/**
 * Created by cqb32_000 on 2016-12-16.
 */

module.exports = {

    "/calculate": function(){
        var mis_id = this.get("mis_id");
        var sen_id = this.get("sen_id");
        var startDate = this.get("startDate");
        var endDate = this.get("endDate");
        var type = this.get("type");

        if(!mis_id){
            this.res.json({
                success: false,
                msg: "mis_id param is needed!"
            });
            return;
        }
        if(!sen_id){
            this.res.json({
                success: false,
                msg: "sen_id param is needed!"
            });
            return;
        }
        if(!type){
            this.res.json({
                success: false,
                msg: "type param is needed!"
            });
            return;
        }else{
            if(type === "process") {
                if (!startDate || !endDate) {
                    this.res.json({
                        success: false,
                        msg: "startDate and endDate param is needed!"
                    });
                    return;
                }
            }
        }

        this.Simulation.doCalculate(mis_id, sen_id, type, startDate, endDate, (times)=>{
            this.res.json(times);
        });
    }
};